import {
  ADD,
  FUNC,
  LOGGER,
  MINUS,
  PROMISES,
  TIMEOUT
} from './store/action-types'

function add() {
  return {
    type: ADD
  }
}

function minus() {
  return {
    type: MINUS
  }
}

function logger() {
  return {
    type: LOGGER
  }
}

function func() {
  return function (dispatch) {
    setTimeout(() => {
      dispatch({ type: FUNC })
    }, 1000)
  }
}

function promises() {
  return new Promise((resolve) => {
    setTimeout(() => {
      debugger
      resolve({
        type: PROMISES
      })
    }, 1500)
  })
}

function timeout() {
  return {
    type: TIMEOUT
  }
}

const actionCreators = {
  add: add(),
  minus: minus(),
  logger: logger(),
  func: func(),
  promises: promises,
  timeout: timeout()
}

export default actionCreators
